package com.atguigu.stgy.admin.controller;

import com.atguigu.stgy.admin.service.FacilityInfoService;
import com.atguigu.stgy.model.entity.FacilityInfo;
import com.atguigu.stgy.admin.service.impl.FacilityInfoServiceImpl;
import com.atguigu.stgy.model.entity.LabelInfo;
import com.atguigu.stgy.model.enums.FacilityTypeEnum;
import com.atguigu.stgy.model.enums.LabelTypeEnum;
import com.atguigu.stgy.model.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 配套信息表(facility_info)表控制层
 *
 * @author xxxxx
 */
@RestController
@Tag(name = "配套信息管理模块")
@RequestMapping("/admin/facility")
public class FacilityInfoController {
    /**
     * 服务对象
     */
    @Resource
    private FacilityInfoService facilityInfoService;

    @Operation(summary = "根据类型查询配套信息列表")
    @GetMapping("/list")
    public R<List<FacilityInfo>> list(@RequestParam(required = false) FacilityTypeEnum type){
        //待条件查询标签列表
        List<FacilityInfo> facilityInfos = facilityInfoService.listFacilityInfoByType(type);
        return R.ok(facilityInfos);
    }

    @Operation(summary = "删除指定配套信息")
    @DeleteMapping("/deleteById")
    public R deleteById(@RequestParam("id")Long id){
        facilityInfoService.removeById(id);
        return R.ok();
    }
    @Operation(summary = "新增或更新标签")
    @PostMapping("/saveOrUpdate")
    public R saveOrUpdate(@RequestBody FacilityInfo facilityInfo){
        facilityInfoService.saveOrUpdate(facilityInfo);
        return R.ok();
    }
}
